Skip to content

Conversation

@ascheman
Copy link
Contributor

Label: Bug

What does this PR do?

It fixes #3263 by providing two changes

  • Close any existing connection on the snapshot DB
  • Drop the database only if it exists

Why is it important?

We had very flaky tests without this change.

Related issues

Seldomly, we still run into #3233 and would be happy about a fix as well.

How to test this PR

As the error(s) only occur in some unknown circumstances it is very hard to enforce their occurrence and also a test situation where they fire.

@ascheman ascheman requested a review from a team as a code owner August 19, 2025 16:37
@netlify
Copy link

netlify bot commented Aug 19, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 240a2ee
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/68a59c3a7fadaa00086466ec
😎 Deploy Preview https://deploy-preview-3264--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ascheman ascheman force-pushed the bugfix/3263-snapshot-restore branch from e9965bc to 1076381 Compare August 19, 2025 16:51
@ascheman ascheman changed the title Fix two problems on snapshot restore fix: Fix two problems on snapshot restore Aug 19, 2025
@ascheman ascheman changed the title fix: Fix two problems on snapshot restore fix: two problems on snapshot restore Aug 19, 2025
@ascheman ascheman force-pushed the bugfix/3263-snapshot-restore branch from 1076381 to 240a2ee Compare August 20, 2025 09:58
Copy link
Contributor

@stevenh stevenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@stevenh stevenh changed the title fix: two problems on snapshot restore fix(postgress): snapshot restore Aug 20, 2025
@stevenh stevenh changed the title fix(postgress): snapshot restore fix(postgres): snapshot restore Aug 20, 2025
@stevenh stevenh merged commit 901b0b9 into testcontainers:main Aug 20, 2025
18 checks passed
@mdelapenya mdelapenya added the bug An issue with the library label Aug 20, 2025
mdelapenya added a commit to knqyf263/testcontainers-go that referenced this pull request Sep 5, 2025
* main: (33 commits)
  feat(registry): add helper functions to pull and tag images (testcontainers#3275)
  fix(reaper): remove termSignal override (testcontainers#3261)
  chore(deps): bump ryuk to v0.13.0, which uses scratch as base image (testcontainers#3274)
  chore(release): refine release script to update inter-module dependencies (testcontainers#3273)
  fix(registry): update `WithHtpasswd` to use `os.CreateTemp` instead of `os.Create` with `filepath.Join`. (testcontainers#3272)
  chore(deps): bump github.com/docker/docker from 28.2.2+incompatible to 28.3.3+incompatible (testcontainers#3270)
  chore(postgres): use require.NotNil instead of assert.NotNil (testcontainers#3252)
  fix(nats): use wait for listening port instead of wait for log (testcontainers#3256)
  chore(deps): bump github.com/go-viper/mapstructure/v2 (testcontainers#3267)
  fix(postgres): snapshot restore (testcontainers#3264)
  fix(dockermcpgateway): use duckduckgo instead of brave (testcontainers#3247)
  feat: add Solace pubsub+ module (testcontainers#3230)
  feat(options): add WithProvider (testcontainers#3241)
  chore(deps): bump github/codeql-action from 3.29.2 to 3.29.3 (testcontainers#3237)
  chore(deps): bump golang.org/x/oauth2 in /modules/weaviate (testcontainers#3240)
  chore(deps): bump mkdocs-include-markdown-plugin from 7.1.5 to 7.1.6 (testcontainers#3239)
  chore(deps): bump requests from 2.32.0 to 2.32.4 (testcontainers#3204)
  feat(mcpgateway): add MCP gateway module (testcontainers#3232)
  chore(deps): bump golang.org/x/oauth2 in /modules/pulsar (testcontainers#3236)
  chore(deps): bump golang.org/x/oauth2 in /modules/gcloud (testcontainers#3235)
  ...
mdelapenya added a commit to mdelapenya/testcontainers-go that referenced this pull request Sep 5, 2025
* main: (30 commits)
  fix: preserve unix socket schema in testcontainers host from properties (testcontainers#3213)
  feat(registry): add helper functions to pull and tag images (testcontainers#3275)
  fix(reaper): remove termSignal override (testcontainers#3261)
  chore(deps): bump ryuk to v0.13.0, which uses scratch as base image (testcontainers#3274)
  chore(release): refine release script to update inter-module dependencies (testcontainers#3273)
  fix(registry): update `WithHtpasswd` to use `os.CreateTemp` instead of `os.Create` with `filepath.Join`. (testcontainers#3272)
  chore(deps): bump github.com/docker/docker from 28.2.2+incompatible to 28.3.3+incompatible (testcontainers#3270)
  chore(postgres): use require.NotNil instead of assert.NotNil (testcontainers#3252)
  fix(nats): use wait for listening port instead of wait for log (testcontainers#3256)
  chore(deps): bump github.com/go-viper/mapstructure/v2 (testcontainers#3267)
  fix(postgres): snapshot restore (testcontainers#3264)
  fix(dockermcpgateway): use duckduckgo instead of brave (testcontainers#3247)
  feat: add Solace pubsub+ module (testcontainers#3230)
  feat(options): add WithProvider (testcontainers#3241)
  chore(deps): bump github/codeql-action from 3.29.2 to 3.29.3 (testcontainers#3237)
  chore(deps): bump golang.org/x/oauth2 in /modules/weaviate (testcontainers#3240)
  chore(deps): bump mkdocs-include-markdown-plugin from 7.1.5 to 7.1.6 (testcontainers#3239)
  chore(deps): bump requests from 2.32.0 to 2.32.4 (testcontainers#3204)
  feat(mcpgateway): add MCP gateway module (testcontainers#3232)
  chore(deps): bump golang.org/x/oauth2 in /modules/pulsar (testcontainers#3236)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue with the library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Multiple errors by PostgreSQL snapshot restore

3 participants